﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace thinger.GenericTeach
{
    public class MyStack<T>
    {
        private int size;
        private T[] stack;
        private int index;

        public MyStack(int size)
        {
            this.size = size;
            this.stack = new T[this.size];
            this.index = -1;
        }

        public void Push(T item)
        {
            index++;
            if (index >= size)
                Console.WriteLine("数据已满...");
            else
                this.stack[index] = item;
        }

        public T Pop()
        {
            T t = this.stack[index];
            index--;
            return t;
        }
    }
}
